import { createStore } from 'vuex'

const defaultState = {
  num: 0
}

export default createStore({
  state() {
    return defaultState
  },
  mutations: {
    setState(state: typeof defaultState) {
      state.num += 1
    }
  },
  actions: {
    increment(context) {
      context.commit('setState')
    }
  },
  getters: {
    double(state: typeof defaultState) {
      return 2 * state.num
    }
  }
})
